// 声明一个变脸计算请求的次数
let ajaxTimes = 0
export const request = (params) => {
  ajaxTimes++;
  wx.showLoading({
    title: '正在加载中...',
  })
  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      // header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      },
      complete: () => {
        ajaxTimes --;
        if (ajaxTimes === 0) {
          wx.hideLoading()
        }
      }
    })
  })

}